package com.jiangds.open.check;

import com.jiangds.open.check.checker.*;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
import java.util.Map;

/**
 * {@link ElementCheck} 校验器简单工厂类
 *
 * @author jiangliang
 * @since 2021/1/7 12:11
 */
public class ElementCheck {

    public static Checker<Integer,String> of(String value){
        return new StringChecker(value);
    }

    public static Checker<Integer,Integer> of(Byte value){
        Integer integer = value == null ? null : value.intValue();
        return new IntegerChecker(integer);
    }

    public static Checker<Integer,Integer> of(Short value){
        Integer integer = value == null ? null : value.intValue();
        return new IntegerChecker(integer);
    }

    public static Checker<Integer,Integer> of(Integer value){
        return new IntegerChecker(value);
    }

    public static Checker<Long,Long> of(Long value){
        return new LongChecker(value);
    }

    public static Checker<Double,Double> of(Float value){
        Double doubleValue = value == null ? null : value.doubleValue();
        return new DoubleChecker(doubleValue);
    }

    public static Checker<Double,Double> of(Double value){
        return new DoubleChecker(value);
    }
    public static Checker<BigDecimal,BigDecimal> of(BigDecimal value){
        return new DecimalChecker(value);
    }

    public static Checker<Integer,LocalDate> of(LocalDate value){
        return new LocalDateChecker(value);
    }

    public static Checker<Integer,Date> of(Date value){
        return new DateChecker(value);
    }

    public static Checker<Integer, LocalDateTime> of(LocalDateTime value){
        return new LocalDateTimeChecker(value);
    }

    public static Checker<Integer,Collection> of(Collection value){
        return new CollectionChecker(value);
    }

    public static Checker<Integer,Map> of(Map value){
        return new MapChecker(value);
    }
}
